package com.docted.design.pattern.singleton;

import com.docted.design.pattern.singleton.serializable.Serializable;

import java.io.*;

/**
 * @author DoCted
 * @since v1.0 2018/3/7
 */
public class SerializableTest {




    public static void main(String[] args) throws IOException, ClassNotFoundException {


        com.docted.design.pattern.singleton.serializable.Serializable s1 = null;
        com.docted.design.pattern.singleton.serializable.Serializable s2 = com.docted.design.pattern.singleton.serializable.Serializable.getInstance();


        FileOutputStream fileOutputStream = new FileOutputStream("Serializable.obj");
        ObjectOutputStream objectOutputStream = new ObjectOutputStream(fileOutputStream);
        objectOutputStream.writeObject(s2);
        objectOutputStream.flush();
        objectOutputStream.close();


        FileInputStream fileInputStream = new FileInputStream("Serializable.obj");
        ObjectInputStream objectInputStream = new ObjectInputStream(fileInputStream);
        s1 = (Serializable) objectInputStream.readObject();
        objectInputStream.close();


        System.out.println(s1 == s2);


    }
}
